
package cloudcode.helloworld.web;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Defines a controller to handle HTTP requests.
 */
@RestController
public final class HelloWorldController {

    /**
     * Create an endpoint for the landing page
     * @return the index view template with a simple message
     */
    @GetMapping("/")
    public String helloWorld() throws UnknownHostException {
        InetAddress ia = InetAddress.getLocalHost();
        String host = ia.getHostName();//获取计算机主机名
        String IP= ia.getHostAddress();//获取计算机IP
        return "hello from pod:"+host+" ip:"+IP;
    }
}
